package mmc.server.shell.ops.baseops;

import mmc.server.shell.*;
import mmc.server.shell.ops.Operation;
import mmc.server.shell.ops.PriorityType;

public class Addition extends Operation {

	boolean isStringConcat;
	
    public Addition(String text) throws ShellException {
        super(text, "+", true, true);
        
        isStringConcat = lValue.getOutputType().equals(String.class)||rValue.getOutputType().equals(String.class);
    }
    
    @Override
    public double execute() {
        return lValue.execute() + rValue.execute();
    }
    
    public Object executeComplex(){
    	if(isStringConcat)
    		return lValue.executeComplex().toString() + rValue.executeComplex().toString();
    	else
    		return execute();
    }
    
    public Class<?> getOutputType(){
    	return isStringConcat?String.class:double.class;
    }
    
    public static PriorityType getPriorityType() {
        return PriorityType.LINE;
    }
    
    public static String getDescription(){
    	return formatHelpString("+","addition");
    }
}
